# -*- coding: utf-8 -*-
# @author: chenhuachao
# @time: 2018/6/29


# import pymysql.cursors
# mysqlconf_formal={
#     "host":"118.89.220.36",
#     "port":3306,
#     "user":"mha_user",
#     "passwd":"gc895316",
#     "db":"bx_abc",
#     "cursorclass":pymysql.cursors.DictCursor,
#      "charset":'utf8'
# }
#
# connection=pymysql.connect(**mysqlconf_formal)
# cursor=connection.cursor()
# cursor.execute("select nid,tags,keywords from bx_news")
# result=cursor.fetchall()
# for i in result:
#     keywords=i.get('keywords')
#     nid=i.get('nid')
#     keywordlist=keywords.split(',')
#     if "None" in keywordlist:
#         print(">>>>>>",keywords)
#         keywordlist.remove("None")
#         if len(keywordlist)>=2:
#             keywordlist=keywordlist[:2]+['保险代理人','买保险']
#         else:
#             keywordlist=keywordlist+['保险代理人','买保险']
#         print("keywordlist=",keywordlist)
#         cursor.execute("update bx_news set keywords='{keywords}'  where nid={nid}".format(
#             keywords=','.join(keywordlist),
#             nid=nid
#         ))
#
# connection.commit()
# connection.close()


